import React, { Component } from 'react'
import { connect } from 'react-redux'
// connect  高阶组件

// 柯里化函数

class Home extends Component {
    render() {
        const { count, add } = this.props
        return (
            <div>
                Home --- { count }
                <button onClick = { add }>+++</button>
            </div>
        )
    }
}

let mapStateToProps = (state) => {
    const { count } = state 
    return {
        count
    }
}

let mapDispatchToProps = (dispatch) => {
    return {
      add() {
        dispatch({ type: "ADD" })
      } 
    }
}
Home = connect(mapStateToProps, mapDispatchToProps)(Home)

export default Home
